// packageD/pages/collect/index.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    active: 1,
    articleList: [],
    quList: [],
    current: 1,
    size: 10
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    wx.setNavigationBarTitle({
      title: '收藏',
    });
    this.getArticleList();
    this.getQuList();
  },

  onClick(event) {
    if (event.detail.name == '精彩文章') {
      // this.getArticleList();
    } else {
      // this.getQuList();
    }
  },
  //获取文章列表
  getArticleList() {
    let params = {
      current: this.data.current,
      size: 10,
    }
    wx.http.get(getApp().globalData.queryCollectArticle,params).then(res => {
      if (res.code == 200) {
        if (this.data.articleList.size == 0) {

          this.setData({
            articleList: res.rows
          })
        } else {
          if (res.total == 0) {
            this.setData({
              articleList: []
            })
          } else {
            this.setData({
              articleList: this.data.articleList.concat(res.rows)
            })
          }
        }
      }
    })
  },

  //获取题目列表
  getQuList() {
    let params = {
      current: this.data.current,
      size: 10,
    }
    wx.http.get(getApp().globalData.collectQuestion, params).then(res => {
      if (res.code == 200) {
        if (this.data.quList.size == 0) {
          this.setData({
            quList: res.rows
          })
        } else {
          if (res.total == 0) {
            this.setData({
              quList: []
            })
          } else {
            this.setData({
              quList: this.data.quList.concat(res.rows)
            })
          }
        }
      }
    })
  },
 //去详情页面
 goto(e){
  wx.setStorageSync('quId', e.currentTarget.dataset.quid)
  wx.navigateTo({
    url: '/packageB/pages/syudy/interview/detail/index',
  })
},
  //滚动到底部/右边时触发
  articleLower(e) {
    this.setData({
      current: this.data.current + 1
    });
    //刷新列表
    this.getArticleList();
  },
  //滚动到底部/右边时触发
  quLower(e) {
    this.setData({
      current: this.data.current + 1
    });
    //刷新列表
    this.getQuList();
  },
  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },


})